package day8;

import java.util.Random;

public class game {
    String name;
    int HP;

    public game() {
    }

    public game(String name, int HP) {
        this.name = name;
        this.HP = HP;
    }

    /**
     * 获取
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 获取
     * @return HP
     */
    public int getHP() {
        return HP;
    }

    /**
     * 设置
     * @param HP
     */
    public void setHP(int HP) {
        this.HP = HP;
    }

    public void attack(String name){
        Random r =new Random();
        int HPcut =r.nextInt(100)+1;
        int remainHP=this.HP-HPcut;
        this.HP=remainHP<0?0:remainHP;
        int skill=r.nextInt(4);
        String []sk={
                "一剑开天门","两袖青蛇","大黄庭","九字真言"
        };
            System.out.printf(name+"使用%s攻击了"+this.name+"造成了"+HPcut+"点伤害，剩余"+this.HP+"点血量。",sk[skill]);
            System.out.println();
    }

}
